//
//  InfoDetailsViewController.m
//  DA_V
//
//  Created by 周季阳 on 15/4/29.
//  Copyright (c) 2015年 zhouhai. All rights reserved.
//

#import "InfoDetailsViewController.h"
#import "InterFace.h"
#import "UIViewAdditions.h"
#import "YoungAllData.h"
@interface InfoDetailsViewController ()<YoungDelegate>
@property(nonatomic,retain)NSString *title;
@property(nonatomic,retain)NSString *content;
@end

@implementation InfoDetailsViewController
@synthesize NoticeID,title,content;
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationController.navigationBarHidden=YES;
    self.view.backgroundColor = [self colorWithHexString:@"#F5F5F5"];
    [self initNav];
    
    navRightBtn.hidden = YES;
    YoungAllData *data = [[YoungAllData alloc]init];
    [data gainInfoDetails:[[NSUserDefaults standardUserDefaults]objectForKey:@"userID"] andNoticeID:NoticeID];
    data.delegate = self;
    
}
#pragma mark - 获取信息详情回调
-(void)infoDetails:(NSDictionary *)sign{
    if ([[sign objectForKey:@"status"] isEqualToString:@"success"]) {
    title = [[sign objectForKey:@"data"] objectForKey:@"Subject"];
    content = [[sign objectForKey:@"data"] objectForKey:@"Content"];
    [self initUI];
    }else{
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:[sign objectForKey:@"reason"] delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alert show];

    }
}
#pragma mark - 信息详情回调失败
-(void)requistFail{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"网络异常,无法加载数据" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
    [alert show];
}
#pragma mark - initUI
-(void)initUI{
    navTitle.text = title;
    
    UIScrollView *scrollview = [[UIScrollView alloc]initWithFrame:CGRectMake(0, navView.bottom, SCREEN_WIDTH, SCREEN_HEIGHT-64-0.15625*SCREEN_WIDTH)];
    scrollview.contentSize = CGSizeMake(SCREEN_WIDTH-40, SCREEN_HEIGHT-200);
    [self.view addSubview:scrollview];
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(20, 20, SCREEN_WIDTH-40, 100)];
    label.text = content;
    label.font = [UIFont systemFontOfSize:13];
    label.numberOfLines = 0;
    label.textColor = [UIColor blackColor];
    label.textAlignment = NSTextAlignmentLeft;
    [scrollview addSubview:label];
    
    UIButton *backNewsButto1n = [UIButton buttonWithType:UIButtonTypeCustom];
    backNewsButto1n.frame = CGRectMake(0, [UIScreen mainScreen].bounds.size.height-(0.15625*SCREEN_WIDTH),SCREEN_WIDTH, 0.15625*SCREEN_WIDTH);
    [backNewsButto1n addTarget:self action:@selector(detailViewBackAction1) forControlEvents:UIControlEventTouchUpInside];
    [backNewsButto1n setBackgroundImage:[UIImage imageNamed:@"bangdingyinhangka-fanhui"] forState:UIControlStateNormal];
    [self.view addSubview:backNewsButto1n];
    NSLog(@"%2f",SCREEN_WIDTH);
    
}
-(void)detailViewBackAction1{
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)backGo{
    [self.navigationController popViewControllerAnimated:YES];
}
#pragma mark - 返回
-(void)clickBackBtn{
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
